﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Entities;
using EntityManage;

namespace ChatClient
{
    public partial class FormLogin : Form
    {
        public FormLogin()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtLoginID.Text == "" || txtPassword.Text == "")
            {
                MessageBox.Show("登录名密码不能为空！");
                return;
            }
            var user = UserManager.Login(txtLoginID.Text, txtPassword.Text);//


            if (user == null)
            {
                MessageBox.Show("用户名或密码错误！");
                return;
            }
            else
            {
                FormFriendsList formFriendsList = new FormFriendsList(user.ID, user.LoginID, user.NickName);
                this.Hide();
                formFriendsList.ShowDialog();
            }
        }

        private void btnRegist_Click(object sender, EventArgs e)
        {
            FormRegist formRegist = new FormRegist();
            this.Hide();
            formRegist.ShowDialog();
            this.ShowDialog();
        }
    }
}
